package com.beiye.drivertransport.activity;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.bean.CheckBean;
import com.beiye.drivertransport.bean.LoginUserBean;
import com.beiye.drivertransport.bean.UpdataBean;
import com.beiye.drivertransport.config.AppInterfaceConfig;
import com.beiye.drivertransport.fragment.HomeFgt;
import com.beiye.drivertransport.fragment.MineFgt;
import com.beiye.drivertransport.fragment.NoticeFragment;
import com.beiye.drivertransport.updata.library.entity.AppUpdate;
import com.beiye.drivertransport.updata.library.listener.MainPageExtraListener;
import com.beiye.drivertransport.updata.library.utils.AppUpdateUtils;
import com.beiye.drivertransport.utils.CameraCanUseUtils;
import com.beiye.drivertransport.utils.MessageEvent;
import com.beiye.drivertransport.utils.PermissionUtils;
import com.beiye.drivertransport.utils.UserManger;
import com.beiye.drivertransport.utils.Utils;
import com.beiye.drivertransport.utils.VersionCodeUtils;
import com.beiye.drivertransport.view.MyRadioButton;
import com.githang.statusbar.StatusBarCompat;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

import okhttp3.Call;
import okhttp3.Response;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.RuntimePermissions;

/**
 * Created by Lc on 2017/11/23.
 */
@RuntimePermissions
public class MainLearnActivity extends TwoBaseAty implements MainPageExtraListener {

    private Context mContext = null;

    FrameLayout mainFrameContent;

    RadioGroup radiogroup;

    MyRadioButton radiobtnHome;
    //    @Bind(R.id.radiobtn_credit_card)
//    MyRadioButton radiobtnCreditCard;

    MyRadioButton radiobtnFind;

    MyRadioButton radiobtnMine;
    //    @Bind(R.id.tv_msg_count)
//    TextView tvMsgCount;

    RelativeLayout rlMsgCountFrame;//红点

    FrameLayout flBottom;

    LinearLayout le_main;
    // 8.0未知应用
    public static final int INSTALL_PACKAGES_REQUESTCODE = 1112;
    public static final int GET_UNKNOWN_APP_SOURCES = 1113;
    //   private int type;
    private List<Fragment> fragments;



    @SuppressLint("HandlerLeak")
    Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            int what = msg.what;
            if (what == 0) {

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                    //MainActivityPermissionsDispatcher.getPermissionWithCheck(MainActivity.this);//新版本权限申请
                } else {//老版本权限申请
                    if (!CameraCanUseUtils.isCameraCanUse()) {
                        ////申请权限——相机
                        PermissionUtils.requestPermission(MainLearnActivity.this, PermissionUtils.CODE_CAMERA, mPermissionGrant, false);
                        return;
                    }
                }


            }
//            else if(what == 1)
//            {//检查更新
//                HTTPCaller.getInstance().get(CheckUpdate.class, AppInterfaceConfig.getRequestUrl("sys/appCheck"),null,requestDataCallback);
//            }
        }
    };

    private AppUpdateUtils updateUtils;
    //private CloudPushService mPushService;
    private Thread thread;

    @Override
    public int getLayoutId() {
        return R.layout.activity_main_learn;
    }


    @Override
    public void initData() {
        mainFrameContent = (FrameLayout) findViewById(R.id.main_frame_content);
        radiogroup = (RadioGroup) findViewById(R.id.radiogroup);
        radiobtnHome = (MyRadioButton) findViewById(R.id.radiobtn_home);
        radiobtnFind = (MyRadioButton) findViewById(R.id.radiobtn_find);
        radiobtnMine = (MyRadioButton) findViewById(R.id.radiobtn_mine);
        rlMsgCountFrame= (RelativeLayout)findViewById(R.id.rl_msg_countFrame);
        flBottom = (FrameLayout) findViewById(R.id.fl_bottom);
        le_main = (LinearLayout) findViewById(R.id.le_main);

        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#1F80C4"));
        //清除缓存文件
        clearData();

        SharedPreferences sp = getSharedPreferences("HintData", Context.MODE_PRIVATE);//首次的指引信息
        boolean isHintProtect = sp.getBoolean("isHintProtect", false);
        if(!isHintProtect){
            //showStatementPopupWindow();
        }

        mContext = this;
        //注册EventBus
        EventBus.getDefault().register(this);
        //     Beta.checkUpgrade(false, false);//bugly更新

        fragments = new ArrayList<>();
        fragments.add(new HomeFgt());
//        fragments.add(new SafeLearnFgt());
//        fragments.add(new LearnRecordsFgt());

        fragments.add(new NoticeFragment());
        //fragments.add(new Notice1Fragment());
        fragments.add(new MineFgt());

        switchFragment(fragments.get(0));
        radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int id) {
                if (id == R.id.radiobtn_home) {
                    switchFragment(fragments.get(0));
                    //                    case R.id.radiobtn_credit_card://
//                        SharedPreferences sp = getSharedPreferences("eeMark", Context.MODE_PRIVATE);
//                        int eeMark = sp.getInt("eeMark", 1);
//                        if (eeMark != 1) {
//                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(MainActivity.this);
//                            builder1.setMessage("此功能仅供驾驶员使用");
//                            builder1.setTitle("提示:");
//                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                                public void onClick(DialogInterface dialog, int which) {
//                                    dialog.dismiss();
//                                    ;
//                                    //设置你的操作事项
//                                }
//                            });
//                            builder1.create().show();
//                            radiobtnCreditCard.setChecked(false);
//                            return;
//                        }
//                        SharedPreferences sp2 = getSharedPreferences("Mark", Context.MODE_PRIVATE);
//                        int mark = sp2.getInt("Mark", 1);
//                        if (mark == 0) {
//                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(MainActivity.this);
//                            builder1.setMessage("您已被企业管理员禁用,请联系企业管理员");
//                            builder1.setTitle("提示:");
//                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                                public void onClick(DialogInterface dialog, int which) {
//                                    dialog.dismiss();
//                                    ;
//                                    //设置你的操作事项
//                                }
//                            });
//                            builder1.create().show();
//                            radiobtnCreditCard.setChecked(false);
//                            return;
//                        } else if (mark == 2) {
//                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(MainActivity.this);
//                            builder1.setMessage("无企业,请联系企业管理员");
//                            builder1.setTitle("提示:");
//                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                                public void onClick(DialogInterface dialog, int which) {
//                                    dialog.dismiss();
//                                    ;
//                                    //设置你的操作事项
//                                }
//                            });
//                            builder1.create().show();
//                            radiobtnCreditCard.setChecked(false);
//                            return;
//                        }
//                        radiobtnCreditCard.setChecked(true);
//                        switchFragment(fragments.get(1));
//                        break;
//                    case R.id.radiobtn_find://
//                        SharedPreferences sp1 = getSharedPreferences("eeMark", Context.MODE_PRIVATE);
//                        int eeMark1 = sp1.getInt("eeMark", 1);
//                        if (eeMark1 != 1) {
//                            TiShiDialog.Builder builder1 = new TiShiDialog.Builder(MainActivity.this
//
//                            );
//                            builder1.setMessage("此功能仅供驾驶员使用");
//                            builder1.setTitle("提示:");
//                            builder1.setPositiveButton("我知道", new DialogInterface.OnClickListener() {
//                                public void onClick(DialogInterface dialog, int which) {
//                                    dialog.dismiss();
//                                    ;
//                                    //设置你的操作事项
//                                }
//                            });
//                            builder1.create().show();
//                            radiobtnFind.setChecked(false);
//                            return;
//                        }
//                        radiobtnFind.setChecked(true);
//                        switchFragment(fragments.get(2));
//                        break;
                } else if (id == R.id.radiobtn_find) {//通知

                    switchFragment(fragments.get(1));
                } else if (id == R.id.radiobtn_mine) {//
                    switchFragment(fragments.get(2));
                }
            }
        });
        thread = new Thread(new Runnable() {
            @Override
            public void run() {
                //在子线程中执行任务，执行完成或需要通知UI线程时调用以下方法
                //休眠3秒
                try {
                    Thread.sleep(1000);
                    mHandler.sendEmptyMessage(0);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }


            }
        });
    }

    //检查更新
    private void initcheckdata() {

        RequestParams params = new RequestParams(AppInterfaceConfig.BASE_URL + "app/version");
        x.http().get(params, new org.xutils.common.Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                UpdataBean updataBean = JSON.parseObject(result, UpdataBean.class);
                String androidforce = updataBean.getAndroidforce();
                String androidmsg = updataBean.getAndroidmsg();
                String androidversion = updataBean.getAndroidversion();
                String androidvname = updataBean.getAndroidvname();
                int force = Integer.parseInt(androidforce);
                int severversion = Integer.parseInt(androidversion);
                int versionCode = VersionCodeUtils.getVersionCode(MainLearnActivity.this);//当前code
                if (severversion == versionCode) {
                    //不处理
                } else if (severversion > versionCode) {
                    if (Utils.isFastClicker()) {
                        return;
                    }
                    //处理业务
                    checkUpdate(force, androidmsg, androidvname);

                }

            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                showToast("网络连接错误");
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

    }

    private void clearData() {
        //清除日常检查出车前sp文件
        SharedPreferences sp1 = getSharedPreferences("VehTeeUrl",
                Context.MODE_PRIVATE);
        if (sp1 != null) {
            SharedPreferences.Editor edit = sp1.edit();
            edit.clear();
            edit.commit();
        }
        //清除日常检查出车中sp文件
        SharedPreferences sp7 = getSharedPreferences("VehTeeUrl1",
                Context.MODE_PRIVATE);
        if (sp7 != null) {
            SharedPreferences.Editor edit = sp7.edit();
            edit.clear();
            edit.commit();
        }
        //清除日常检查出车后sp文件
        SharedPreferences sp8 = getSharedPreferences("VehTeeUrl2",
                Context.MODE_PRIVATE);
        if (sp8 != null) {
            SharedPreferences.Editor edit = sp8.edit();
            edit.clear();
            edit.commit();
        }
        //清除安全例检sp文件
        SharedPreferences sp2 = getSharedPreferences("VehTeeUrl6",
                Context.MODE_PRIVATE);
        if (sp2 != null) {
            SharedPreferences.Editor edit1 = sp2.edit();
            edit1.clear();
            edit1.commit();
        }
        //清除日常检查的隐患排查sp1文件
        SharedPreferences sp3 = getSharedPreferences("VehTeeUrl4",
                Context.MODE_PRIVATE);
        if (sp3 != null) {
            SharedPreferences.Editor edit2 = sp3.edit();
            edit2.clear();
            edit2.commit();
        }
        //清除日常检查的隐患排查sp2文件
        SharedPreferences sp4 = getSharedPreferences("VehTeeUrl5",
                Context.MODE_PRIVATE);
        if (sp4 != null) {
            SharedPreferences.Editor edit3 = sp4.edit();
            edit3.clear();
            edit3.commit();
        }
        //清除安全路检的隐患排查sp1文件
        SharedPreferences sp5 = getSharedPreferences("VehTeeUrl7",
                Context.MODE_PRIVATE);
        if (sp5 != null) {
            SharedPreferences.Editor edit4 = sp5.edit();
            edit4.clear();
            edit4.commit();
        }
        //清除安全路检的隐患排查sp2文件
        SharedPreferences sp6 = getSharedPreferences("VehTeeUrl8",
                Context.MODE_PRIVATE);
        if (sp6 != null) {
            SharedPreferences.Editor edit5 = sp6.edit();
            edit5.clear();
            edit5.commit();
        }
        //清除角色文件
        SharedPreferences sp9 = getSharedPreferences("role", Context.MODE_PRIVATE);
        if (sp9 != null) {
            SharedPreferences.Editor edit5 = sp9.edit();
            edit5.clear();
            edit5.commit();
        }
        //清除驾驶员课程超市
        SharedPreferences sp10 = getSharedPreferences("CourseDetailsActivity",
                Context.MODE_PRIVATE);
        if (sp10 != null) {
            SharedPreferences.Editor edit5 = sp10.edit();
            edit5.clear();
            edit5.commit();
        }
        //清除驾驶员考卷1
        SharedPreferences sp11 = getSharedPreferences("ExaminationActivity",
                Context.MODE_PRIVATE);
        if (sp11 != null) {
            SharedPreferences.Editor edit5 = sp11.edit();
            edit5.clear();
            edit5.commit();
        }
        //清除驾驶员考卷2
        SharedPreferences sp12 = getSharedPreferences("score",
                Context.MODE_PRIVATE);
        if (sp12 != null) {
            SharedPreferences.Editor edit5 = sp12.edit();
            edit5.clear();
            edit5.commit();
        }
        //清除驾驶员考卷3
        SharedPreferences sp13 = getSharedPreferences("opition",
                Context.MODE_PRIVATE);
        if (sp13 != null) {
            SharedPreferences.Editor edit5 = sp13.edit();
            edit5.clear();
            edit5.commit();
        }
        //首页清空数据
        SharedPreferences sp14 = getSharedPreferences("homefgt", Context.MODE_PRIVATE);
        if (sp14 != null) {
            SharedPreferences.Editor edit5 = sp14.edit();
            edit5.clear();
            edit5.commit();
        }
    }

    private List<Fragment> loadFragments = new ArrayList<>();

    private void switchFragment(Fragment fragment) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        if (loadFragments.contains(fragment)) {
            reSetFragment(fragment);
        } else {
            fragmentTransaction.add(R.id.main_frame_content, fragment).commit();
            loadFragments.add(fragment);
        }
    }

    private void reSetFragment(Fragment fragment) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        for (Fragment loadFragment : loadFragments) {
            fragmentTransaction.hide(loadFragment);
        }
        fragmentTransaction.show(fragment);
        fragment.onResume();
        fragmentTransaction.commit();
    }


    @Override
    public void requestData() {
        //initcheckdata();//自己服务器检查版本是否有更新
        LoginUserBean userInfo = UserManger.getUserInfo();
        LoginUserBean.DataBean data = userInfo.getData();
        if (data == null) {
            return;
        }
        String userId = data.getUserId();

        /*mPushService = PushServiceFactory.getCloudPushService();
        mPushService.addAlias(userId, new CommonCallback() {
            @Override
            public void onSuccess(String s) {
                LogUtils.e("测试", "onSuccess: "+s+"别名添加成功" );
            }

            @Override
            public void onFailed(String s, String s1) {

            }
        });*/

        //通知红点
        OkGo.get(AppInterfaceConfig.BASE_URL + "sys/notice/getUnViewStatus/" + userId)
                .tag(this)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String result, Call call, Response response) {

                        CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
                        Integer data1 = checkBean.getData();
                        if (data1 == 0) {
                            rlMsgCountFrame.setVisibility(View.GONE);
                        } else if (data1 >= 1) {
                            rlMsgCountFrame.setVisibility(View.VISIBLE);
                        }
                    }

                    @Override
                    public void onError(Call call, Response response, Exception e) {
                        super.onError(call, response, e);

                    }
                });


    }


    private void checkUpdate(int force, String androidmsg, String androidvname) {
        updateUtils = new AppUpdateUtils(MainLearnActivity.this);
        AppUpdate appUpdate = new AppUpdate.Builder()
                //更新地址
                .newVersionUrl(AppInterfaceConfig.apkPath)
                // 版本号
                .newVersionCode(androidvname)
                .updateInfo(androidmsg)
                // 通过传入资源id来自定义更新对话框，注意取消更新的id要定义为btnUpdateLater，立即更新的id要定义为btnUpdateNow
                .updateResourceId(R.layout.dialog_update)
                //是否采取静默下载模式（只显示更新提示，后台下载完自动弹出安装界面），否则，显示下载进度，显示下载失败弹框
                .isSilentMode(false)
                //默认0不采取强制更新,1强制更新否则，不更新无法使用
                .forceUpdate(force)
                //正常更新时apk下载失败，指引去应用宝市场下载
                .downBrowserUrl("https://a.app.qq.com/o/simple.jsp?pkgname=com.beiye.drivertransport&channel=0002160650432d595942&fromcase=60001")
                .build();
        updateUtils.startUpdate(appUpdate, this);


    }


    private long exitTime = 0;

    @RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
    @Override
    public void onBackPressed() {
        if ((System.currentTimeMillis() - exitTime) > 2000) {
            Toast.makeText(getApplicationContext(), "再按一次离开驾运宝", Toast.LENGTH_SHORT).show();
            exitTime = System.currentTimeMillis();
        } else {
            //彻底关闭整个APP
            int currentVersion = Build.VERSION.SDK_INT;
            if (currentVersion > Build.VERSION_CODES.ECLAIR_MR1) {
                Intent startMain = new Intent(Intent.ACTION_MAIN);
                startMain.addCategory(Intent.CATEGORY_HOME);
                startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(startMain);
                System.exit(0);
            } else {// android2.1
                ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
                am.restartPackage(getPackageName());
            }
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);//反注册EventBus
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(MessageEvent event) {
        if (event.getMessage() == "Activityfinish") {
            finish();
        }
    }


    @Override
    protected void onResume() {
        LoginUserBean userInfo = UserManger.getUserInfo();
        LoginUserBean.DataBean data = userInfo.getData();
        if (data == null) {
            return;
        }
        String userId = data.getUserId();
        //通知红点
        OkGo.get(AppInterfaceConfig.BASE_URL + "sys/notice/getUnViewStatus/" + userId)
                .tag(this)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String result, Call call, Response response) {

                        CheckBean checkBean = JSON.parseObject(result, CheckBean.class);
                        Integer data1 = checkBean.getData();
                        if (data1 == 0) {
                            rlMsgCountFrame.setVisibility(View.GONE);
                        } else if (data1 >= 1) {
                            rlMsgCountFrame.setVisibility(View.VISIBLE);
                        }
                    }

                    @Override
                    public void onError(Call call, Response response, Exception e) {
                        super.onError(call, response, e);

                    }
                });

        super.onResume();
    }

    /**
     * 权限授予通过，回调
     */
    private PermissionUtils.PermissionGrant mPermissionGrant = new PermissionUtils.PermissionGrant() {
        @Override
        public void onPermissionGranted(int requestCode) {
            switch (requestCode) {
                case PermissionUtils.CODE_CAMERA:
                    //   ToastUtil.showShortToast(MainActivity.this,"相机权限已授予");
                    // TODO: 后续相关操作
                    //摄像头

                    break;

                default:
                    break;
            }
        }
    };

    @Override
    public void forceExit() {
        // 如果使用到了强制退出，需要自己控制
        finish();
        System.exit(0);
    }

    /**
     * 检测到无权限安装未知来源应用，回调接口中需要重新请求安装未知应用来源的权限
     */
    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    public void applyAndroidOInstall() {
        //请求安装未知应用来源的权限
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.REQUEST_INSTALL_PACKAGES}, INSTALL_PACKAGES_REQUESTCODE);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        // 8.0的权限请求结果回调
        if (requestCode == INSTALL_PACKAGES_REQUESTCODE) {
            // 授权成功
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                installApkAgain();
            } else {
                // 授权失败，引导用户去未知应用安装的界面
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    //注意这个是8.0新API
                    Uri packageUri = Uri.parse("package:" + getPackageName());
                    Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageUri);
                    startActivityForResult(intent, GET_UNKNOWN_APP_SOURCES);
                }
            }
        }
        //MainActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults); //新版本权限申请回调方法
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //8.0应用设置界面未知安装开源返回时候
        if (requestCode == GET_UNKNOWN_APP_SOURCES) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                boolean allowInstall = getPackageManager().canRequestPackageInstalls();
                if (allowInstall) {
                    installApkAgain();
                } else {
                    Toast.makeText(MainLearnActivity.this, "您拒绝了安装未知来源应用，应用暂时无法更新！", Toast.LENGTH_SHORT).show();
                    if (0 != updateUtils.getAppUpdate().getForceUpdate()) {
                        forceExit();
                    }
                }
            }
        }
    }

    //个人信息保护指引
    private void showStatementPopupWindow() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        View view1 = View.inflate(MainLearnActivity.this, R.layout.pop_userinfo_protect, null);

        AlertDialog dialog = builder.create();
        dialog.show();
        dialog.getWindow().setContentView(view1);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.setCancelable(false);

        TextView tvKnow = (TextView) view1.findViewById(R.id.pw_statement_tv_know);
        LinearLayout llSeeDetail = (LinearLayout) view1.findViewById(R.id.pw_statement_ll_seeDetail);


        tvKnow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                SharedPreferences sp = getSharedPreferences("HintData", Context.MODE_PRIVATE);//首次的指引信息
                SharedPreferences.Editor spEdit=sp.edit();
                spEdit.putBoolean("isHintProtect",true);
                spEdit.commit();
                thread.start();
            }
        });
    }

    private void installApkAgain() {
        if (updateUtils != null) {
            updateUtils.installAppAgain();
        }
    }

    //新版本权限申请方法
    @NeedsPermission({Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    void getPermission() {
    }
}

